package cn.edu.csust.coursecard.controller;

import cn.edu.csust.coursecard.dao.entity.Advice;
import cn.edu.csust.coursecard.common.ReturnData;
import cn.edu.csust.coursecard.service.AdviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * @author zsw
 * @date 2019/12/18 16:03
 * @author 许大人
 * @date 2022/08/15 09:35
 */
@Validated
@RestController
@RequestMapping("advice")
public class AdviceController {

	@Autowired
	AdviceService adviceService;

	@Valid
	@PostMapping("/add")
	public ReturnData addAdvice(HttpServletRequest request, @Validated Advice advice){
		return adviceService.addAdvice(request, advice);
	}

	@GetMapping("getAdvice")
	public ReturnData getAdvice(HttpServletRequest request,Integer id){
		return adviceService.getAdvice(request,id);
	}

	@GetMapping("getAllAdvice")
	public ReturnData getAllAdvice(HttpServletRequest request){
		return adviceService.getAllAdvice(request);
	}

	@GetMapping("/delete")
	public ReturnData deleteAdvice(HttpServletRequest request,Integer id){
		return adviceService.deleteAdvice(request,id);
	}

	@GetMapping("deleteAll")
	public ReturnData deleteAllAdvice(HttpServletRequest request){
		return adviceService.deleteAllAdvice(request);
	}

}
